package com.atguigu.gulimall.product.service;

import com.atguigu.gulimall.product.entity.AttrEntity;
import com.atguigu.gulimall.product.vo.AttrRespVO;
import com.atguigu.gulimall.product.vo.AttrVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @Author: fd
 * @Date 2021/5/15 21:37
 * @Description: 这里的@Mapper来源于org.mapstruct.Mapper，用来说明这是一个实体转换类接口。
 * @Mappings用来声明成员属性的映射，source = "name",target = "attrName"
 * 即将AttrVO中name的值拷贝给AttrEntity中的attrName，如果属性名称相同，就不需要做这个映射。
 */
@Mapper(componentModel = "spring")
public interface AttrConverter {

	AttrConverter INSTANCE = Mappers.getMapper(AttrConverter.class);

	/**
	 * 对象映射
	 * @author fd
	 * @date 2021/5/16 15:28
	 * @param attrVO
	 * @return com.atguigu.gulimall.product.entity.AttrEntity
	 */
	AttrEntity copyProperties(AttrVO attrVO);


	/**
	 * 对象映射
	 * @author fd
	 * @date 2021/5/16 16:30
	 * @param attrEntity
	 * @return com.atguigu.gulimall.product.entity.AttrEntity
	 */
	AttrRespVO EntityToAttrRespVo(AttrEntity attrEntity);
}
